#include<bits/stdc++.h>
using namespace std;
int t,ans1,n,m,l,vmax,ls,bj[3005][3005],b[200005],js[200005],bj1,bj2;
struct{
    int jsd,jl,v;
}a[200005];
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    while(t--)
    {
        ans1 = 0;
        ls = -1;
        bj1 = 0;
        bj2 = 0;
        cin>>n>>m>>l>>vmax;
        for(int i = 0;i<n;i++)
        {
            cin>>a[i].jl>>a[i].v>>a[i].jsd;
            if(a[i].jsd != 0)
                bj1 = 1;
            if(a[i].jsd < 0)
                bj2 = 1;
        }
        for(int i = 0;i<m;i++)
        {
            cin>>b[i];
        }
        if(bj1 == 0)
        {
            for(int i = 0;i<n;i++)
            {
                if(a[i].v>vmax)
                    ans1++;
            }
            cout<<ans1<<" "<<m-1<<endl;
            continue;
        }
        if(bj2 == 0)
        {
            for(int i = 0;i<n;i++)
            {
                ls = a[i].v*a[i].v+2*a[i].jsd*(b[m-1]-a[i].jl);
                if(ls>vmax*vmax)
                    ans1++;
            }
            cout<<ans1<<" "<<m-1<<endl;
            continue;
        }
        for(int i = 0;i<n;i++)
        {
            for(int j = 0;j<m;j++)
            {
                if(b[j]>=a[i].jl)
                {
                    ls = a[i].v*a[i].v+2*a[i].jsd*(b[j]-a[i].jl);
                    if(ls>vmax*vmax)
                    {
                        bj[i][j] = 1;
                        js[i] = 1;
                    }
                }
            }
        }
        for(int i = 0;i<n;i++)
        {
            if(js[i] == 1)
                ans1++;
        }
        cout<<3<<" "<<3<<endl;
        return 0;
    }

}
